package com.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.entity.Preorder;
import com.entity.PreorderPlus;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface PreorderMapper extends BaseMapper<Preorder> {
//查询功能
    List<Preorder> selectPage();
//删除功能
    @Delete("delete from preorder where g_id = #{g_id} AND t_id = #{t_id} AND p_date = #{p_date}")
    int delPreorder(@Param("g_id") int g_id,@Param("t_id") int t_id,@Param("p_date") String p_date);
//更新功能
    @Update("UPDATE preorder SET  p_state = #{p_state} WHERE g_id = #{g_id} AND t_id = #{t_id} AND p_date = #{p_date}")
    int updatePreorder(@Param("g_id") int g_id,@Param("t_id") int t_id,@Param("p_date") String p_date ,@Param("p_state")int p_state) ;

    @Select("select c_name,uname,start_time,end_time,p_date,p_state,g_id,t_id,u_id from preorder,user,ground,time_tb where ground.id = preorder.g_id and time_tb.id = preorder.t_id and user.id= preorder.u_id")
    List<PreorderPlus> preorderInfo();
}
